// 护理管理 / 地址管理

import r from '@/utils/request';
import type { ListParams, ListResponseType, ResponseType } from '../types';

enum API {
    list = '/address/list', //地址列表
    del = '/address/delete/', //删除地址
    add = '/address/add', //添加地址
    update = '/address/update',//修改地址
    delAll = '/address/deleteAll'//批量删除地址
}
type GetaddresslistResType = ListResponseType<{
    id:        number;
    companyId: number;
    name:      string;
    qrcode:    string;
}>


export interface AdressAddParams{
    name:   string;
    qrcode: string;
}

type AddressaddResType = ResponseType<{
    id:        number;
    companyId: number;
    name:      string;
    qrcode:    string;
}>




export interface AddressUpdateParams {
    id:     number;
    name:   string;
    qrcode: string;
}
type AddressUpdateResType = ResponseType<{
    id:        number;
    companyId: number;
    name:      string;
    qrcode:    string;
}>

export function addresslistAPI(params: ListParams): Promise<GetaddresslistResType> {
    return r.get(API.list, params);
}

export function DelAddressAPI(id: number): Promise<ResponseType<null>> {
    return r.delete(API.del + id);
}
export function AddresssAddAPI(params: AdressAddParams): Promise<AddressaddResType> {
    return r.post(API.add, params);
}



export function FoodsUpdateAPI(params: AddressUpdateParams): Promise<AddressUpdateResType> {
    return r.put(API.update, params);
}


export function DelAllAddressAPI(id: number[]): Promise<ResponseType<null>> {
    return r.post(API.delAll, id);
}